package com.ruoyi.anfang.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.anfang.domain.MoMessageUser;
import com.ruoyi.anfang.service.IMoMessageUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报警联系人Controller
 * 
 * @author wzy
 * @date 2024-07-16
 */
@RestController
@RequestMapping("/anfang/messageUser")
public class MoMessageUserController extends BaseController
{
    @Autowired
    private IMoMessageUserService moMessageUserService;

    /**
     * 查询报警联系人列表
     */
    @PreAuthorize("@ss.hasPermi('anfang:messageUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(MoMessageUser moMessageUser)
    {
        startPage();
        List<MoMessageUser> list = moMessageUserService.selectMoMessageUserList(moMessageUser);
        return getDataTable(list);
    }

    /**
     * 导出报警联系人列表
     */
    @PreAuthorize("@ss.hasPermi('anfang:messageUser:export')")
    @Log(title = "报警联系人", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MoMessageUser moMessageUser)
    {
        List<MoMessageUser> list = moMessageUserService.selectMoMessageUserList(moMessageUser);
        ExcelUtil<MoMessageUser> util = new ExcelUtil<MoMessageUser>(MoMessageUser.class);
        util.exportExcel(response, list, "报警联系人数据");
    }

    /**
     * 获取报警联系人详细信息
     */
    @PreAuthorize("@ss.hasPermi('anfang:messageUser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(moMessageUserService.selectMoMessageUserById(id));
    }

    /**
     * 新增报警联系人
     */
    @PreAuthorize("@ss.hasPermi('anfang:messageUser:add')")
    @Log(title = "报警联系人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MoMessageUser moMessageUser)
    {
        return toAjax(moMessageUserService.insertMoMessageUser(moMessageUser));
    }

    /**
     * 修改报警联系人
     */
    @PreAuthorize("@ss.hasPermi('anfang:messageUser:edit')")
    @Log(title = "报警联系人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MoMessageUser moMessageUser)
    {
        return toAjax(moMessageUserService.updateMoMessageUser(moMessageUser));
    }

    /**
     * 删除报警联系人
     */
    @PreAuthorize("@ss.hasPermi('anfang:messageUser:remove')")
    @Log(title = "报警联系人", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(moMessageUserService.deleteMoMessageUserByIds(ids));
    }
}
